﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using E.Web.UI.Page;
using E.Model;
using X.Common;
using E.Enum;
using E.BLL;

namespace E.Web.Teacher.internals.exam
{
    public partial class PaperInspect : TeacherBasePage
    {

        public TestDetailInfoModel model = new TestDetailInfoModel();
        public string[] serialNo = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
        public string act;
        public string testidAndUserid;

        protected override void ShowPage()
        {
            act = XRequest.GetString("act");
            //int testid = XRequest.GetInt("id", -1);
            testidAndUserid = XRequest.GetString("id");
            string[] splitTestAndUserId = testidAndUserid.Split((new string[1]{";"}),StringSplitOptions.None);
            int testid = int.Parse(splitTestAndUserId[0]);
            int userid = int.Parse(splitTestAndUserId[1]);
            //testid = 86;
            if (testid != -1)
            {
                model = (new QuestionBLL()).GetTestDetailInfo(testid, userid);
            }


            if (ispost || act == "save")
            {

                if (model.SubjectiveAnswerArray.Length > 0)
                {
                    for (int i = 0; i < model.SubjectiveAnswerArray.Length; i++)
                    {
                        int updateSubjectiveScore = XRequest.GetInt("subjectQuestionScore_" + i, 0);
                        model.SubjectScore[i] = updateSubjectiveScore;
                    }
                    (new QuestionBLL()).UpdateSubjectiveScoreAndTotalScore(model.TestLogId, model);
                    
                }
                string href = "/internals/exam/PaperList.aspx";
                ExecuteJS("window.location = '" + href + "';");
            }
        }

        public string GetSerialNo(int index)
        {
            return serialNo[index - 1];
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}